global bootloader

extern bootloader_main

STACKSIZE equ 0x4000 ; 16KB

; multiboot header - see GRUB docs for details
MODULEALIGN equ  1<<0                   ; align loaded modules on page boundaries
MEMINFO     equ  1<<1                   ; provide memory map
FLAGS       equ  MODULEALIGN | MEMINFO
MAGIC       equ  0x1BADB002             ; the magic number lets the bootloader find the header
CHECKSUM    equ  -(MAGIC + FLAGS)

section .text
    jmp bootloader
    align 4
    multiboot_header:
       dd MAGIC
       dd FLAGS
       dd CHECKSUM

    bootloader:
        cli

        mov esp, stack

        push dword 0
        popf

        push eax ; multiboot magic number
        push ebx ; multiboot info structure
        call bootloader_main

    halt:
       hlt
       jmp halt

section .data


section .bss
    align 32
       resb STACKSIZE
    stack:
